package com.aaa.ssm.service.impl;

import com.aaa.ssm.dao.SysCareerDao;
import com.aaa.ssm.entity.Patient;
import com.aaa.ssm.entity.SchedulingInfo;
import com.aaa.ssm.entity.SysCareer;
import com.aaa.ssm.service.SysCareerService;
import com.aaa.ssm.util.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SysCareerServiceImpl implements SysCareerService {
    @Resource
    private SysCareerDao sysCareerDao;

    @Override
    public SysCareer checkUser(Integer careerId, String password) {
        SysCareer sysCareer=new SysCareer();

        sysCareer.setCareerId(careerId);
        sysCareer.setPassword(password);
        System.out.println(sysCareer+"+++++++++++++++++++++++++++++++++++++++++++++++++++++++============");
            List<SysCareer> userList=sysCareerDao.queryLogin(sysCareer);
            if (userList!=null&&userList.size()>0){
                return userList.get(0);
            }
            return null;
        }


    @Override
    public List<SysCareer> queryByParam(SysCareer sysCareer) {
        return sysCareerDao.queryByParam(sysCareer);
    }

    @Override
    public SysCareer queryById(Integer careerId) {
        return sysCareerDao.queryById(careerId);
    }

    @Override
    public int add(SysCareer sysCareer) {
        return sysCareerDao.add(sysCareer);
    }

    @Override
    public int update(SysCareer sysCareer) {
        return sysCareerDao.update(sysCareer);
    }

    @Override
    public int deleteById(Integer careerId) {
        return sysCareerDao.deleteById(careerId);
    }

    @Override
    public PageInfo queryByPage(Page<SysCareer> page) {
        //设值分页参数   startPage(int pageNum, int pageSize)  pageNum 第几页  pageSize 页面
        PageHelper.startPage(page.getPageNo(), page.getPageSize());
        return new PageInfo(sysCareerDao.queryByParam(page.getData()));
    }

    @Override
    public boolean querySchedulingInfo(Integer careerId, String dateString) {
        List<SchedulingInfo> schedulingInfoList = sysCareerDao.querySchedulingInfo(careerId, dateString);
        if (!CollectionUtils.isEmpty(schedulingInfoList)){
            return true;
        }
        return false;
    }

    @Override
    public List<SysCareer> queryAll(SysCareer sysCareer) {
        return null;
    }

}
